package com.iflytek.utils;

import com.iflytek.utils.enums.ResultEnum;
import com.iflytek.vo.ResultData;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ResultUtil {

    public static final String CODE = "code";
    public static final String MSG = "msg";
    public static final String MSG_TEXT = "删除成功";

    public static <T> ResultData success(Long count, List<T> data) {
        return new ResultData(ResultData.SUCCESS_CODE, "请求成功", count, data);
    }


    public static <T> ResultData failure() {
        return new ResultData(ResultData.FAILURE_CODE, "请求失败", 0L, null);
    }

    public static Map<String, Object> success(String msg) {
        Map<String, Object> map = new HashMap<>();
        map.put(MSG, msg);
        map.put(CODE, 0);
        return map;
    }

    public static Map<String, Object> failure(String msg) {
        Map<String, Object> map = new HashMap<>();
        map.put(MSG, msg);
        map.put(CODE, 1);
        return map;
    }


    public static Map<String, Object> resultMap(Integer code) {
        Map<String, Object> map = new HashMap<>();
        map.put(MSG, ResultEnum.msg(code));
        map.put(CODE, code);
        return map;
    }


}
